package com.example.kotlindemo620

import android.os.Bundle
import android.os.Process
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment

class TailFragment : Fragment() {

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        val view = inflater.inflate(R.layout.fragment_tail, container, false)

        view.findViewById<View>(R.id.btn_block).setOnClickListener {
            // 阻塞主线程5秒
            Thread.sleep(5000)
        }

        view.findViewById<View>(R.id.btn_crash).setOnClickListener {
            // 强制退出应用
            Process.killProcess(Process.myPid())
            System.exit(1)
        }
        return view
    }
}